﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Net.NetworkInformation;
using Microsoft.VisualBasic;
using Ionic.Zip;





///scris de Popa Alexandru Stefan    disablealex@yahoo.de

namespace AION_LAUNCHER
{
    public partial class Form1 : Form
    {
  
        public Form1()
        {
            this.DoubleBuffered = true;
            InitializeComponent();
          
        }

        private void vistaButton1_Click(object sender, EventArgs e)//launch
        {
            try
            {
                Properties.Settings s = new Properties.Settings();
                string c = s.Setting;
                
                string command = ("/c " + c);
               // MessageBox.Show(command);
                ProcessStartInfo cmdsi = new ProcessStartInfo("cmd.exe");
                cmdsi.Arguments = command;
                cmdsi.WindowStyle = ProcessWindowStyle.Hidden;

                Process.Start(cmdsi);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error!Launcher not in AION Folder!","Incorrect Location",MessageBoxButtons.RetryCancel,MessageBoxIcon.Error);
            
            }
        }

        private void vistaButton2_Click(object sender, EventArgs e)//site
        {
            Process.Start("http://www.aionspeed.com/");
        }

        private void vistaButton3_Click(object sender, EventArgs e)//forum
        {
            Process.Start("http://speedcommunity.net/");
        }

        private string PingTheBastard()
        {
            string strhost = "46.4.55.238";
            Ping pingSender = new Ping();
            PingOptions options = new PingOptions();
            options.DontFragment = true;
            
            string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
            byte[] buffer = Encoding.ASCII.GetBytes(data);
            int timeout = 120;
            try
            {
                
                
                PingReply reply = pingSender.Send(strhost, timeout, buffer, options);
                if (reply.Status == IPStatus.Success) return "ONLINE";
                else
                    return "OFFLINE";
            }
            catch (Exception ex)
            { return ex.Message; }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text = PingTheBastard();

            if (label1.Text == "ONLINE")
            {
                label1.ForeColor = System.Drawing.Color.Green;
            }
            else
                label1.ForeColor = System.Drawing.Color.Red;
        }
    }
}
